package com.woniu.user.controller;


import cn.hutool.core.lang.Snowflake;
import com.woniu.user.commons.Result;
import com.woniu.user.controller.form.VenueApplyForm;
import com.woniu.user.model.VenueApply;
import com.woniu.user.service.VenueApplyService;
import com.woniu.user.util.BeanCopyUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * <p>
 * 场馆入驻申请表 前端控制器
 * </p>
 *
 * @author Silas
 * @since 2023-02-15
 */
@RestController
@RequestMapping("/venueApply")
@Slf4j
@Api(tags = "场馆入驻申请")
public class VenueApplyController {

    @Resource
    private VenueApplyService venueApplyService;

    @PostMapping("/getApplyInfo")
    @ApiOperation("场馆入驻")
    public Result getApplyInfo(@RequestBody VenueApplyForm venueApplyForm) {
        log.info("执行入驻操作 {}",venueApplyForm);
        VenueApply va = BeanCopyUtil.copyObject(venueApplyForm, VenueApply.class);
        va.setState("审核中");
        va.setTime(LocalDateTime.now());
        va.setNo(new Snowflake(1,1).nextIdStr());
        venueApplyService.save(va);
        return Result.success(200,"入驻成功",venueApplyForm);
    }
}

